<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class IndexController extends CommonController{

	//构造函数
	public function __init()
	{
	}
	
    //动作
    public function index(){
//        (1)获取顶级分类
       $cateModel=new \Common\Model\Cate();
       $cateName=$cateModel->where("pid=0")->get();
//        p($cateName);die;
//        (2)获取左侧菜单
       foreach($cateName as $k=>$u ){
               $cateName[$k]['son']=$cateModel->where("pid={$cateName[$k]['cid']}")->get();
       }

//        (3)获取左侧品牌分类
        $brandModel=new \Common\Model\Brand();
        $brandData=$brandModel->join('commodity cd','bid','=','cd.shop_brand_bid')->orderBy('bsort','desc')->groupBy('bid')->limit(8)->get();

//        (4)获取左侧热销商品分类
        $commodityModel=new \Common\Model\Commod();
        $commodData=$commodityModel->orderBy('coclick','desc')->limit(8)->get();

//        (5)获取手机的分类
        $mobelName=$cateModel->where("pid=8")->get();
        //    (6)获得网页主体手机分类的数据
        $mobileData1=$commodityModel->where("shop_category_cid=35")->limit(8)->get();
        $mobileData2=$commodityModel->where("shop_category_cid=36")->limit(8)->get();
        $mobileData3=$commodityModel->where("shop_category_cid=37")->limit(8)->get();
        $mobileData4=$commodityModel->where("shop_category_cid=38")->limit(8)->get();
        $mobileData5=$commodityModel->where("shop_category_cid=39")->limit(8)->get();
        $mobileData6=$commodityModel->where("shop_category_cid=40")->limit(8)->get();
        $mobileData7=$commodityModel->where("shop_category_cid=41")->limit(8)->get();

//        (7)获得平板电脑的数据
        $pingbanData=$commodityModel->join('category c','shop_category_cid','=','cid')->where("pid=5")->limit(8)->get();
//        (8)获得智能设备的数据
        $zhinengData=$commodityModel->join('category c','shop_category_cid','=','cid')->where("pid=6")->limit(8)->get();
//        (9)获得配件类的数据
        $peijianData=$commodityModel->join('category c','shop_category_cid','=','cid')->where("pid=17")->limit(8)->get();
//        (10)搜索框下热门搜索
        $hotsouData=$commodityModel->orderBy('coclick','desc')->limit(4)->get();
//       p($brandData);die;
        View::with('hotsouData',$hotsouData);
        View::with('peijianData',$peijianData);
        View::with('zhinengData',$zhinengData);
        View::with('pingbanData',$pingbanData);
        View::with('mobileData1',$mobileData1);
        View::with('mobileData2',$mobileData2);
        View::with('mobileData3',$mobileData3);
        View::with('mobileData4',$mobileData4);
        View::with('mobileData5',$mobileData5);
        View::with('mobileData6',$mobileData6);
        View::with('mobileData7',$mobileData7);
       View::with('cateName',$cateName);
       View::with('brandData',$brandData);
       View::with('commodData',$commodData);
       View::with('mobelName',$mobelName);
       View::make();
    }


}
